package com.study.talk.module.entity;

import com.alibaba.fastjson2.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;

/**
 * <p>
 * 
 * </p>
 *
 * @author thor
 * @since 2023-12-18
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("group_user_info")
@ApiModel(value = "GroupUserInfo对象", description = "")
public class GroupUserInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("id")
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @ApiModelProperty("群聊id")
    private Integer groupId;

    @ApiModelProperty("用户id")
    private Integer userId;

    @ApiModelProperty("用户昵称")
    private String userName;

    @ApiModelProperty("用户头像地址")
    private String userAvatar;

    @ApiModelProperty("用户简介")
    private String userIntroduce;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    @JSONField(format="yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    public GroupUserInfo(UserInfo userInfo, Integer groupId) {
        this.groupId = groupId;
        this.userId = userInfo.getId();
        this.userName = userInfo.getNickName();
        this.userAvatar = userInfo.getAvatar();
        this.userIntroduce = userInfo.getIntroduce();
    }
}
